package com.jzlw.huozhuduan.dialog;

import android.app.Dialog;
import android.content.Context;
import android.view.animation.Animation;
import android.view.animation.LinearInterpolator;
import android.view.animation.RotateAnimation;
import android.widget.ImageView;

import com.jzlw.huozhuduan.R;


/**
 * ClassName MainDialog
 * Description
 * Author sunrong
 * Date 2019/6/3 15:00
 */
public class MainDialog extends Dialog {
    private ImageView ivProgress;
    RotateAnimation rotate;


    public MainDialog(Context context) {
        super(context, R.style.MyDialog);
        setContentView(R.layout.view_main_dialog);//dialog布局文件
        setCanceledOnTouchOutside(false);//点击外部不允许关闭dialog
        ivProgress = (ImageView) findViewById(R.id.ivProgress);
        rotate = new RotateAnimation(0f, 360f, Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
        LinearInterpolator lin = new LinearInterpolator();
        rotate.setInterpolator(lin);
        rotate.setDuration(1500);//设置动画持续时间
        rotate.setRepeatCount(-1);//设置重复次数
        rotate.setFillAfter(true);//动画执行完后是否停留在执行完的状态
//        rotate.setStartOffset(10);//执行前的等待时间

    }


    @Override
    public void dismiss() {
        super.dismiss();
        rotate.cancel();
    }

    @Override
    public void show() {
        ivProgress.startAnimation(rotate);
        super.show();
    }
}

